local skel = fk.CreateSkill {
  name = "emo__shejian",
}

Fk:loadTranslationTable{
  ["emo__shejian"] = "舌剑",
  [":emo__shejian"] = "当你使用牌指定第一个目标后，你可以对体力值与此牌牌名字数相等的一名目标角色造成1点伤害。",

  ["#emo__shejian-choose"] = "舌剑：你可以对其中体力值与此牌牌名字数相等的1名角色造成1点伤害",

  ["$emo__shejian1"] = "尔等刀兵之利，犹不及吾之唇舌尔！",
  ["$emo__shejian2"] = "将军拥兵十万，我以言剑尽斩之！",
}

skel:addEffect(fk.TargetSpecified, {
  anim_type = "control",
  can_trigger = function (self, event, target, player, data)
    if player == target and player:hasSkill(skel.name) and data.firstTarget then
      local len = Fk:translate(data.card.trueName, "zh_CN"):len()
      return table.find(data.use.tos, function (to)
        return to.hp == len
      end) ~= nil
    end
  end,
  on_cost = function (self, event, target, player, data)
    local len = Fk:translate(data.card.trueName, "zh_CN"):len()
    local targets = table.filter(data.use.tos, function (to)
      return to.hp == len
    end)
    if #targets == 0 then return false end
    local tos = player.room:askToChoosePlayers(player, {
      min_num = 1, max_num = 1, targets = targets, skill_name = skel.name,
      prompt = "#emo__shejian-choose",
    })
    if #tos > 0 then
      event:setCostData(self, {tos = tos})
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local to = event:getCostData(self).tos[1]
    room:damage { from = player, to = to, damage = 1, skillName = skel.name }
  end,
})

return skel
